import pytest
import os
import subprocess
import logging
import time


'''
动态拼接测试文件路径，方便不同平台及环境使用，通过夹具维护
'''
current_path = os.getcwd()
@pytest.fixture(scope='module')
def department_case_data_path():

    data_relative_path=r'test_data\test_data.json'
    file_path=os.path.join(current_path,data_relative_path)
    return file_path

@pytest.fixture(scope='module')
def link_case_data_path():
    data_relative_path=r'test_data\interface_list.csv'
    file_path=os.path.join(current_path,data_relative_path)
    return file_path

#pytst的钩子函数，在会话开始前会执行一次,入参config可以是配置文件
def pytest_configure(config:None):
    # 设置日志记录配置
    current_path = os.getcwd()
    log_data_path = os.path.join(current_path, 'log')
    if not os.path.exists(log_data_path):
        os.mkdir(log_data_path)

    logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s',
                            filename=f"{log_data_path}/pytest_automation.log",
                            filemode='w')
print(os.getcwd())